From: Jason Andryuk Date: Tue, 20 May 2014 13:37:08 +0000 (-0400) Subject: libxc: Protect xc_domain_resume from clobbering domain registers X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~4963 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=84acc84afbd1bd859cd31d44831db77da6ade960;p=xen.git libxc: Protect xc_domain_resume from clobbering domain registers xc_domain_resume() expects the guest to be in state SHUTDOWN_suspend. However, nothing verifies the state before modify_returncode() modifies the domain's registers. This will crash guest processes or the kernel itself. This can be demonstrated with `LIBXL_SAVE_HELPER=/bin/false xl migrate`. Signed-off-by: Jason Andryuk Acked-by: Ian Campbell --- diff --git a/tools/libxc/xc_resume.c b/tools/libxc/xc_resume.c index 18b4818426..e4238142d8 100644 --- a/tools/libxc/xc_resume.c +++ b/tools/libxc/xc_resume.c @@ -33,12 +33,21 @@ static int modify_returncode(xc_interface *xch, uint32_t domid) struct domain_info_context *dinfo = &_dinfo; int rc; - if ( xc_domain_getinfo(xch, domid, 1, &info) != 1 ) + if ( xc_domain_getinfo(xch, domid, 1, &info) != 1 || + info.domid != domid ) { PERROR("Could not get domain info"); return -1; } + if ( !info.shutdown || (info.shutdown_reason != SHUTDOWN_suspend) ) + { + ERROR("Dom %d not suspended: (shutdown %d, reason %d)", domid, + info.shutdown, info.shutdown_reason); + errno = EINVAL; + return -1; + } + if ( info.hvm ) { /* HVM guests without PV drivers have no return code to modify. */